<template>
  <div>
    <!-- <el-form
      :inline="true"
      :model="searchIdentity"
      class="demo-form-inline"
      style="margin-top: 25px; margin-left: 30%"
    >
      <el-form-item label="被举报人身份">
        <el-select
          v-model="searchIdentity"
          placeholder="请选择身份"
          @change="changePBoardId"
        >
          <el-option label="学生" value="0"></el-option>
          <el-option label="教师" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="searchCommentUser">查询</el-button>
      </el-form-item>
    </el-form> -->
    <el-table :data="userList" border style="width: 1076px; margin: auto">
      <el-table-column
        prop="nickName"
        label="被举报人昵称"
        width="125"
        align="center"
      >
      </el-table-column>
      <!-- <el-table-column label="被举报人身份" width="125" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.identity === 0">学生</div>
          <div v-if="scope.row.identity === 1">教师</div>
        </template>
      </el-table-column> -->
      <el-table-column label="状态" width="75" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.states === 1">正常</div>
          <div v-if="scope.row.states === 0" style="color: red">已禁言</div>
        </template>
      </el-table-column>
      <el-table-column
        prop="userNickName"
        label="举报人昵称"
        width="125"
        align="center"
      >
      </el-table-column>
      <el-table-column label="举报原因" width="225" align="center">
        <template slot-scope="scope">
          <div class="multiple-overflow">
            {{ scope.row.desc }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="400" align="center">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-more"
            @click="checkDetails(scope.row.desc)"
            >举报详情</el-button
          >

          <el-button
            type="success"
            size="mini"
            icon="el-icon-delete"
            @click="ignoreTipOff(scope.row.tipoffId)"
            >忽略举报</el-button
          >
          <el-button
            type="danger"
            size="mini"
            v-if="scope.row.states === 1"
            icon="el-icon-turn-off"
            @click="banStudent(scope.row.userId)"
            >禁言</el-button
          >
          <el-button
            type="success"
            v-if="scope.row.states === 0"
            icon="el-icon-open"
            @click="cancelBan(scope.row.userId)"
            >解禁</el-button
          >
          <!-- <el-button
            type="danger"
            size="mini"
            v-if="scope.row.states === 1 && scope.row.identity === 0"
            icon="el-icon-turn-off"
            @click="banTeacher(scope.row.teacherId)"
            >禁言</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :current-page="currentPage"
      :total="totalRecords"
      :page-size="limit"
      :page-sizes="[5, 10, 15, 20, 25, 30, 35]"
      style="margin: 30px 0; text-align: center"
      layout="sizes,prev,pager,next,jumper,->,total,slot"
      @current-change="getStudentList"
      @size-change="changeSize"
    />
  </div>
</template>

<script>
import adminControll from "@/api/adminControll";
export default {
  data() {
    return {
      searchIdentity: "",
      currentPage: 1,
      limit: 5,
      totalRecords: 100,
      userList: [
        {
          tipoffId: "",
          studentId: "",
          states: 0,
          nickName: "Xzh",
          identity: 0,
          userNickName: "Mike",
          desc: "该用户的私聊用语十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: "",
          studentId: "",
          states: 1,
          nickName: "Xzh",
          identity: 0,
          userNickName: "Mike",
          desc: "该用户的私聊用语十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          studentId: "",
          tipoffId: "",
          states: 0,
          nickName: "Xzh",
          identity: 0,
          userNickName: "Mike",
          desc: "该用户的私聊用语十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: "",
          teacherId: "",
          states: 1,
          nickName: "Xzh",
          identity: 1,
          userNickName: "Mike",
          desc: "该用户的私聊用语十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
        {
          tipoffId: "",
          teacherId: "",
          nickName: "Xzh",
          states: 0,
          identity: 1,
          userNickName: "Mike",
          desc: "该用户的私聊用语十分低俗该文章的内容十分低俗该文章的内容十分低俗该文章的内容十分低俗",
        },
      ],
    };
  },

  components: {},

  computed: {},

  created() {
    this.getAllTipOff(3, null, this.currentPage, this.limit);
  },

  methods: {
    searchCommentUser() {},
    changeSize(size) {
      this.limit = size;
      this.getStudentList(1);
    },
    getStudentList(page = 1) {},
    changePBoardId(value) {
      console.log(value);
    },
    checkDetails(desc) {
      this.$alert(desc, "举报描述详情", {
        confirmButtonText: "取消",
      });
    },
    ignoreTipOff(tipoffId) {
      this.$alert("您确定忽略该举报吗", "举报详情", {
        confirmButtonText: "确定",
        callback: (action) => {},
      });
    },
    //将学生禁言
    banStudent(studentid) {
      this.$alert("您确定禁言该用户吗", "禁言详情", {
        confirmButtonText: "确定",
        callback: (action) => {
          if (action == "confirm") {
            adminControll.updateIsForbidden(0, studentid).then((response) => {
              this.searchStudent(
                this.currentPage,
                this.limit,
                this.searchStudentVo
              );
            });
          }
        },
      });
    },
    //解除学生禁言
    cancelBan(studentid) {
      this.$alert("您确定取消该用户的禁言吗", "取消详情", {
        confirmButtonText: "确定",
        callback: (action) => {
          if (action == "confirm") {
            adminControll.updateIsForbidden(1, studentid).then((response) => {
              this.searchStudent(
                this.currentPage,
                this.limit,
                this.searchStudentVo
              );
            });
          }
        },
      });
    },
    getAllTipOff(type, searchType, pageNo, pageSize) {
      adminControll
        .getAllTipOff(type, searchType, pageNo, pageSize)
        .then((response) => {
          if (response.data != null) {
            this.userList = response.data.records;
            this.totalRecords = response.data.total;
          }
        });
    },
  },
};
</script>
<style scoped>
img {
  display: block;
  width: 75px;
  height: 75px;
}
.exceed {
  color: red;
}
/* 单行溢出处理 */
p {
  width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.multiple-overflow {
  width: 175px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
</style>
